/***************************************************************************//**
 * @file MSc_Angles.cpp
 * @author  Marek M. Cel <marekcel@mscsim.org>
 *
 * @section LICENSE
 *
 * Copyright (C) 2013 Marek M. Cel
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 ******************************************************************************/
#ifndef MSC_ANGLES_CPP
#define MSC_ANGLES_CPP
#endif

////////////////////////////////////////////////////////////////////////////////

#include <sstream>

#include "MSc_Angles.h"

////////////////////////////////////////////////////////////////////////////////

MSc_Angles::MSc_Angles()
{
    m_phi = 0.0;
    m_tht = 0.0;
    m_psi = 0.0;
}

////////////////////////////////////////////////////////////////////////////////

MSc_Angles::MSc_Angles( const MSc_Angles &angl )
{
    m_phi = angl.m_phi;
    m_tht = angl.m_tht;
    m_psi = angl.m_psi;
}

////////////////////////////////////////////////////////////////////////////////

MSc_Angles MSc_Angles::getFrom( double phi, double tht, double psi )
{
    MSc_Angles result;

    result.set( phi, tht, psi );

    return result;
}

////////////////////////////////////////////////////////////////////////////////

bool MSc_Angles::isValid() const
{
    return ( MSc_Utils::isValid( m_phi )
          && MSc_Utils::isValid( m_tht )
          && MSc_Utils::isValid( m_psi ) );
}

////////////////////////////////////////////////////////////////////////////////

void MSc_Angles::set( double phi, double tht, double psi )
{
    m_phi = phi;
    m_tht = tht;
    m_psi = psi;
}

////////////////////////////////////////////////////////////////////////////////

std::string MSc_Angles::toString()
{
    std::stringstream ss;

    ss << m_phi << "," << m_tht << "," << m_psi;

    return ss.str();
}

////////////////////////////////////////////////////////////////////////////////

MSc_Angles& MSc_Angles::operator= ( const MSc_Angles &angl )
{
    m_phi = angl.m_phi;
    m_tht = angl.m_tht;
    m_psi = angl.m_psi;

    return (*this);
}

////////////////////////////////////////////////////////////////////////////////

bool MSc_Angles::operator== ( const MSc_Angles &angl ) const
{
    return ( ( m_phi == angl.m_phi )
          && ( m_tht == angl.m_tht )
          && ( m_psi == angl.m_psi ) );
}

////////////////////////////////////////////////////////////////////////////////

bool MSc_Angles::operator!= ( const MSc_Angles &angl ) const
{
    return !( (*this) == angl );
}
